import React, { Component } from 'react';

import Child1 from './child1'
import Child2 from './child2'
class Father1 extends Component {
    state = {
        salary1: 100,
        salary2: 200
    }
    render() {
        return (
            <div>
                我是父组件
                <Child1 salary1={this.state.salary1}></Child1>
                <button onClick={this.addSalary1Fn}>child1涨薪水+10</button>
                <Child2 salary2={this.state.salary2}></Child2>
                <button onClick={this.addSalary2Fn}>child2涨薪水+20</button>
            </div>
        );
    };
    addSalary1Fn = () => {
        this.setState({
            salary1: this.state.salary1 + 10
        })
    };
    addSalary2Fn = () => {
        this.setState({
            salary2: this.state.salary2 + 20
        })
    }
}

export default Father1;
